home *** CD-ROM | disk | FTP | other *** search
- /* Example request saver. This program is very simple and should probably be
- made more OS compatible (I mean the ReadArgs() function).
-
- IMPORTANT: To protect ReqOFF againts going into infinitive loop (when your
- requester replacer calls EasyRequestArgs() with same TITLE and/or TEXT
- as the original requester) you should add a single space as a first byte
- of title string, or simply change it to other title which will not qualify
- to be patched by your program again and again and again...
-
- IMPORTANT: In 'replacerdata' structure you receive not only the easystruc,
- but also the screen pointer, idcmp and args with which the main
- EasyRequestArgs was called. The 1st thing is that is not guaranteed that the
- screen is still opened (I think it's better to call EasyRequestArgs() with
- a NIL/NULL screen pointer because all users probably use DefaultPubScreen
- patches). The 2nd is that idcmp and args may be passed incorrectly by
- ReqOFF/other software (???) because mine programs hanged with these args
- passed to EasyRequestArgs - so don't use them!
- */
-
- MODULE 'dos/dos','other/replacer','intuition/intuition'
-
- DEF pos,newtitle:PTR TO LONG,exit=0,fh,file[101]:STRING
- DEF re:PTR TO replacerdata
-
- PROC main()
- IF StrCmp(arg,'"',1) -> the 1st arg is log file name
- pos:=InStr(arg,'"',1) -> which has to be specified in
- StrCopy(file,arg+1,pos-1) -> RAPrefsMUI
- ELSE
- pos:=InStr(arg,' ',1)
- StrCopy(file,arg,pos) -> now the file variable contains
- ENDIF -> the file name (without quotas)
-
-
- pos:=InStr(arg,'0x',0) -> replace all 0x with ' $'
- arg[pos]:=$20;arg[pos+1]:=$24 -> Val() needs hexadecimal numbers...
- re:=Val(arg+pos,0) -> (get the value)
- -> ...to be preceded by '$'
-
- IF newtitle:=New(StrLen(re.easystr.title)+2)-> title MUST be preceded by a space
- -> we do not want an infinitive loop!
- StringF(newtitle,' \s',re.easystr.title)
- -> now call the requester...
- exit:=EasyRequestArgs(0,[20,0,newtitle,re.easystr.textformat,re.easystr.gadgetformat],0,0)
- -> and add info to the log file...
- IF fh:=Open(file,MODE_READWRITE)
- Seek(fh,0,OFFSET_END) -> skip to EOF
-
- /* Now we dont need the file name anymore, so we can use it to prepare
- the text to write in log file... */
-
- MidStr(file,re.easystr.title,0,20);StringF(file,'TITLE:\s ',file);
- Fputs(fh,file) -> write the title...
-
- MidStr(file,re.easystr.textformat,0,30);StringF(file,'TEXT:\s ',file);
- removenextline();Fputs(fh,file)-> write the text...
-
- MidStr(file,re.easystr.gadgetformat,0,15);StringF(file,'BUTT:\s EXIT:\d\n',file,exit);
- Fputs(fh,file)-> write the button info and exit #...
-
- Close(fh)
- ENDIF
- ENDIF
- ENDPROC exit
-
- /* This procedure checks all bytes in string for $0a (next line) and replaces
- it with $20 - space */
- PROC removenextline()
- DEF no
- FOR no:=0 TO StrLen(file)
- IF file[no]=$0a;file[no]:=$20;ENDIF
- ENDFOR
- ENDPROC
-